package com.imooc.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
@Slf4j
public class IndexTask {

//    @Resource
    private IndexTask indexTask;


//    @PostConstruct
    public void task() {
        indexTask.dosame();
    }

    @Async
    public synchronized void dosame() {

        while (true) {
            log.info("dosame");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

}
